<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/7/23 14:02
 * Modified Time: 2019/7/23 14:02
 * Version: 2.0
 */

namespace App\Modules\System\Controllers;


use App\Modules\System\Services\ImageService;
use Flower\Core\Http\BaseController;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

class ImageController extends BaseController
{
    private $imageService;

    public function __construct(ImageService $imageService)
    {
        $this->imageService = $imageService;
    }

    public function uploadImg(Request $request)
    {
        $img = $this->imageService->upload($request->all());

        return $this->display($img, '上传成功');
    }

    public function getShareImage(Request $request)
    {
        return $this->imageService->getShareImage();
    }

    /**
     * 上传OSS的图片，是一个访问路径
     * @param Request $request
     * @return mixed
     */
    public function uploadOSSImage(Request $request)
    {
        $data = $this->imageService->addByOSSUrl($request->image_url);
        return $this->display($data, '上传成功');
    }

}